import App from './App'
import request from './utils/request.js'

// 添加请求拦截器
request.addRequestInterceptor(
  (config) => {
    // console.log('请求拦截器:', config)
	// console.log('请求拦截器:', JSON.parse(JSON.stringify(config)));
    return config
  },
  (error) => {
    console.error('请求拦截器错误:', error)
    return Promise.reject(error)
  }
)

// 添加响应拦截器
request.addResponseInterceptor(
  (response) => {
    // console.log('响应拦截器:', response)
	// request.showToast(response.data.message || '业务处理失败');
    return response
  },
  (error) => {
    console.error('响应拦截器错误:', error)
    return Promise.reject(error)
  }
)


// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
  ...App
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)
    app.config.globalProperties.request = request;
  return {
    app
  }
}
// #endif